<?php

namespace App\Http\Controllers\Console;

class ProjectController extends CommonController
{
    protected $RULE = [
        'insert' => [
            'title' => 'required|max:60',
            'vname' => 'required',
            'token' => 'required',
            'keywords' => 'required',
            'description' => 'required',
            'intro' => 'required',
            'rank' => 'required|numeric',
            'status' => 'required|numeric',
            'common_param.*' => 'required|max:60',
            'common_type.*' => 'required',
            'common_limited.*' => 'required',
            'common_required.*' => 'required|numeric',
            'common_description.*' => 'required',
            'error_code.*' => 'required|max:60',
            'error_description.*' => 'required',
            'error_title.*' => 'required',
        ],

        'update' => [
            'title' => 'required|max:60',
            'vname' => 'required',
            'token' => 'required',
            'keywords' => 'required',
            'description' => 'required',
            'intro' => 'required',
            'rank' => 'required|numeric',
            'status' => 'required|numeric',
            'common_param.*' => 'required|max:60',
            'common_type.*' => 'required',
            'common_limited.*' => 'required',
            'common_required.*' => 'required|numeric',
            'common_description.*' => 'required',
            'error_code.*' => 'required|max:60',
            'error_description.*' => 'required',
            'error_title.*' => 'required',
        ],
    ];

    public function requestDataFormat($data, $opt = [])
    {
        $request = request();
        if ($request->hasFile('pic')) {
            $path = $this->upload('pic');

            if (false === $path) {
                return $this->output(10005, $this->getUploadError());
            }
            $data['pic'] = $path;
            return $data;
        } else {
            return $data;
        }
    }
}
